<div class="jumbotron simple">
    <div class="container">
        <h1><?php echo $cat->name?></h1>
    </div>
</div>


<div id="container-main" class="container">
    <div class="row">
        <div class="col-md-18">

            <?php if(!$cat->parent_id):?>
                <?php $this->renderPartial('//hangve/page/_panel_forum', array('catData' => $cat))?>
                <?php endif?>


            <ul class="nav nav-tabs" id="post-tab">
                <li <?php if($model->sort == 'upped'):?>class="active"<?php endif?>><a data-toggle="tab" rel="upped">Cập nhật mới</a></li>
                <li <?php if($model->sort == 'created'):?>class="active"<?php endif?>><a data-toggle="tab" rel="created">Chủ đề mới</a></li>                
                <li <?php if($model->sort == 'reply_count'):?>class="active"<?php endif?>><a data-toggle="tab" rel="reply_count">Trả lời nhiều</a></li>                
                <li <?php if($model->sort == 'view_count'):?>class="active"<?php endif?>><a data-toggle="tab" rel="view_count">Xem nhiều</a></li>
                <li <?php if($model->sort == 'price'):?>class="active"<?php endif?>><a data-toggle="tab" rel="price">Rẻ nhất</a></li>
            </ul>

            <?php /*
                Lọc: Thành phố, quận huyện

                SALE: 
                - Loại tin: mua , bán
                - Tình trạng: cũ, mới, gần như mới
                - Giá:

                IMMOVABLE: 
                - Loại tin: mua , bán, thuê, cho thuê
                - Diện tích sử dụng:
                - Diện tích mặt bằng:
                - Giá: 
                SERVICE:
                - Giá: 

                ARTICLE:

                Sắp xếp:
                - Cập nhật mới
                - Chủ đề mới
            */?>
            <div class="row margintop20">

                <?php $form=$this->beginWidget('CActiveForm', array(
                        'id'=>'filter_form',
                        'action'=>Yii::app()->createUrl($this->route),
                        'method'=>'get',
                    )); ?>
                <?php echo $form->hiddenField($model,'sort',array('size'=>10,'maxlength'=>10)); ?>
                <?php if(in_array($cat->type, array('SALE', 'IMMOVABLE', 'SERVICE'))):?>
                    <div class="form-group col-lg-4 col-md-6 col-sm-8 col-xs-12">
                        <?php echo $form->label($model,'city_id'); ?>
                        <?php echo $form->dropDownList($model, 'city_id', City::model()->data, array('class'=>'form-control input-sm', 'empty' => 'Toàn quốc')); ?>
                    </div>
                    <div class="form-group col-lg-4 col-md-6 col-sm-8 col-xs-12">
                        <?php echo $form->label($model,'district_id'); ?>
                        <?php echo $form->dropDownList($model, 'district_id', $districtData, array('class'=>'form-control input-sm', 'empty' => 'Tất cả')); ?>
                    </div>
                    <?php endif?>

                <?php if(in_array($cat->type, array('SALE', 'IMMOVABLE'))):?>
                    <div class="form-group col-lg-4 col-md-6 col-sm-8 col-xs-12">
                        <?php echo $form->label($model,'type'); ?>
                        <?php echo $form->dropDownList($model, 'type', $typeData, array('class'=>'form-control input-sm', 'empty' => 'Tất cả')); ?>
                    </div>
                    <?php endif?>

                <?php if($cat->type == 'SALE'):?>
                    <div class="form-group col-lg-4 col-md-6 col-sm-8 col-xs-12">
                        <?php echo $form->label($model,'state'); ?>
                        <?php echo $form->dropDownList($model, 'state', $model->stateData, array('class'=>'form-control input-sm', 'empty' => 'Tất cả')); ?>
                    </div>
                    <?php endif?>

                <?php if($cat->type == 'IMMOVABLE'):?>
                    <div class="form-group col-lg-4 col-md-6 col-sm-8 col-xs-12">
                        <?php echo $form->label($model,'area_use_about'); ?>
                        <?php echo $form->dropDownList($model, 'area_use_about', $model->areaAboutData, array('class'=>'form-control input-sm', 'empty' => 'Tất cả')); ?>
                    </div>
                    <div class="form-group col-lg-4 col-md-6 col-sm-8 col-xs-12">
                        <?php echo $form->label($model,'area_floor_about'); ?>
                        <?php echo $form->dropDownList($model, 'area_floor_about', $model->areaAboutData, array('class'=>'form-control input-sm', 'empty' => 'Tất cả')); ?>
                    </div>

                    <?php endif?>

                <?php if(in_array($cat->type, array('SALE', 'IMMOVABLE', 'SERVICE'))):?>
                    <div class="form-group col-lg-4 col-md-6 col-sm-8 col-xs-12">
                        <?php echo $form->label($model,'price_from'); ?>
                        <?php echo $form->dropDownList($model, 'price_from', $model->priceData, array('class'=>'form-control input-sm', 'empty' => 'Tất cả')); ?>
                    </div>
                    <div class="form-group col-lg-4 col-md-6 col-sm-8 col-xs-12">
                        <?php echo $form->label($model,'price_to'); ?>
                        <?php echo $form->dropDownList($model, 'price_to', $model->priceData, array('class'=>'form-control input-sm', 'empty' => 'Tất cả')); ?>
                    </div>
                    <div class="form-group col-lg-4 col-md-6 col-sm-8 col-xs-12">
                        <?php echo $form->label($model,'status'); ?>
                        <?php echo $form->dropDownList($model, 'status', $model->getStatusData(false), array('class'=>'form-control input-sm', 'empty' => 'Tất cả')); ?>
                    </div>
                    <div class="form-group col-lg-4 col-md-6 col-sm-8 col-xs-12">
                        <label></label>
                        <div class="form-control">
                            <?php echo $form->checkBox($model,'has_image'); ?>
                            <?php echo $form->label($model,'has_image', array(
                                    'style' => 'display: inline', 
                                    'label' => '<abbr rel="tooltip" title="Chỉ hiển thị những bài có ảnh">'.$model->getAttributeLabel('has_image').'</abbr>'
                                )); ?>
                        </div>
                    </div>
                    <div class="form-group col-lg-4 col-md-6 col-sm-8 col-xs-12" id="is_all_city_block" <?php if(!$model->city_id):?> style="display: none;"<?php endif?>>
                        <label></label>
                        <div class="form-control">
                            <?php echo $form->checkBox($model,'is_all_city'); ?>
                            <?php echo $form->label($model,'is_all_city', array(
                                    'style' => 'display: inline', 
                                    'label' => '<abbr rel="tooltip" title="Hiển thị cả những bài được chọn rao toàn quốc">'.$model->getAttributeLabel('is_all_city').'</abbr>'
                                )); ?>
                        </div>
                    </div>
                    <?php endif?>

                <?php $this->endWidget(); ?>
            </div>


            <?php $this->widget('zii.widgets.grid.CGridView', array(
                    'id'=>'post-list',
                    'dataProvider'=>$dataProvider,
                    'filter'=>null,
                    'ajaxUpdate'=> true,
                    'beforeAjaxUpdate'=>'function(id,options){
                    $("#ajax-loading").fadeIn();
                    }',
                    'afterAjaxUpdate'=>'function(id,options){
                    $("#ajax-loading").fadeOut();
                    }',
                    'template' => "{items} {pager}",
                    'itemsCssClass' => 'table table-striped table-hover ',
                    //'pagerCssClass' => 'pagination pagination-centered',
                    'pager'=>array(
                        'class'=>'CLinkPager',
                        'htmlOptions' => array(
                            'class' => 'pagination',
                        ),
                        'hiddenPageCssClass' => 'disabled',
                        'selectedPageCssClass' => 'active',
                        'maxButtonCount'    =>  10,
                        'header'            => false,
                    ),
                    'loadingCssClass' => '',
                    'columns'=>array(
                        array(
                            'header' => 'Ảnh đại diện',
                            'type'      =>  'html',
                            'value' => '$data->image',
                            'headerHtmlOptions' => array('style' => 'width: 40px'),
                        ),
                        array(
                            'header' => 'Tiêu đề',
                            'type'      =>  'html',
                            'value' => '$data->title',
                        ),
                        array(
                            'header' => 'Trả lời / Lượt xem',
                            'type'      =>  'html',
                            'value' => '$data->title',
                        ),
                        array(
                            'header' => 'Bài viết cuối',
                            'type'      =>  'html',
                            'value' => '$data->title',
                        ),
                    ),
                )); ?>
        </div>
        <div class="col-md-6">
            <?php $this->renderPartial('//common/sidebar')?>
        </div>
    </div>
</div>
<script>var districtDataGroupByCityId = <?php echo json_encode(District::model()->getDataGroupByCity())?>;</script>
<script type="text/javascript" src="<?php echo $this->themeUrl?>/files/js/post_index.js"></script> 








